<?php
print "<a name=\"image_{$this->entity->id}\"></a>";

if ($this->entity->picid) {
switch($this->entity->pictype) {

case 0:case 1:

if (isset($params['maxwidth'])) {
if ($this->entity->picsize[0] > $params['maxwidth']) {
$percentage = $params['maxwidth'] / $this->entity->picsize[0];
$this->entity->picsize[0] = $params['maxwidth'];
$this->entity->picsize[1] = ($percentage * $this->entity->picsize[1]);
}
}

$divclasses[] = "imageholder";

if ($this->entity->picclass) {
$divclasses[] = $this->entity->picclass;
}

if ($this->entity->floats[$this->entity->picfloat]) {
$divclasses[] = $this->entity->floats[$this->entity->picfloat];
}

print"\n<div style=\"width: " . $this->entity->picsize[0] . "px;\"";
print " class=\"" . implode(" ", $divclasses) . "\">\n";


if ($version == "pretail") {
$this->entity->Window_PretailBox();
}

/*
if ($this->entity->hyperlink) {
$this->entity->hyperlink->OpenLink();
}
*/

/*
if ($this->entity->openinpopup AND $this->entity->rendering) {
$this->entity->Popup(0);
}
*/

print "<img width=\"" . $this->entity->picsize[0] . "\" height=\"" . $this->entity->picsize[1] . "\"";
print " src=\"" . $this->entity->picpath . "\" alt=\"" . $this->entity->picfile->picalt . "\"";

$picclasses = NULL;
if ($this->entity->borders[$this->entity->picborder]) {
$picclasses[] = $this->entity->borders[$this->entity->picborder];
}

if ($this->entity->picclass) {
$picclasses[] = $this->entity->picclass;
}

if ($picclasses) {
print " class=\"" . implode(" ", $picclasses) . "\"";
}

print " />\n";

/*
if ($this->entity->openinpopup AND $this->entity->rendering) {
$this->entity->Popup(1);
}

/*
if ($this->entity->hyperlink) {
$this->entity->hyperlink->CloseLink();
}
*/

if ($this->entity->pictype == 1) {
print "<div class=\"text\">\n";
print $this->entity->pictitle;
print "\n</div>\n";
}
print"</div>";
break;

case 2:

if ($this->entity->openinpopup AND $this->entity->rendering) {
$this->entity->Popup(0);
}
print "<img width=\"" . $this->entity->picsize[0] . "\" height=\"" . $this->entity->picsize[1] . "\" ";
print "src=\"" . $this->entity->picpath . "\" alt=\"" . $this->entity->picfile->picalt . "\"";
print " />";
if ($this->entity->openinpopup AND $this->entity->rendering) {
$this->entity->Popup(1);
}



break;
}
} else {
if ($version == "pretail") {
$this->entity->Window_PretailBox();
}
}
